Skip to main content

Version 1.3.0-alpha.5

NPM Install

npm install @mentaport/certificates

Checkout our examples to get started.

Initializing SDK

To initialize the Certificate SDK, simply provide your API Key and an optional Environment parameter (the default setting is 'production').

import { CertificateSDK } from '@mentaport/certificates';

// server side recommended
_mentaportSDK = new CertificateSDK(apiKey);
_mentaportSDK.setClientEnv(env?:Environment);

Creating Certificates

When creating a new certificate, we first watermark the content and approve the provided information. Once approved, the certificate is issued, and the newly watermarked content becomes available for download.

1. Creating a Certificate

    /**
* Function to create a certificate
*
* @param {ICertificateArg} ICertificateArg
* - @param {projectId} ProjectId
* - @param {contentFormat} ContentFormat (png, mp3..)
* - @param {name} Name of certificate
* - @param {username} Public name
* - @param {description} Description of work
* - @param {usingAI} Boolean
* - @param {aiTrainingMiningInfo} AITrainingMiningInfo
* - @param {certId} CertId (optional) Use if updating NonActive certificate
* - @param {aiSoftware} (optional) AI software used
* - @param {aiModel} (optional) AI model used
* - @param {album} (optional) Album name
* - @param {albumYear} (optional) Album year
*
* @param {blobContent} File to uplaod
*
* @returns {IResults<ICertificate>} Returns initializing certificate.
*/
const result = await _mentaportSDK.createCertificate(
initCertificateArgs: ICertificateArg,
blobContent:Blob);

Once the content is uploaded, the status of the certificate will change from NonActive to Initialized.

2. Check Certificate Status

Depending on the type of content you are watermarking (image, audio, video), the watermarking process can vary in time, typically taking about 1-20 seconds. Check the status until the content has successfully been watermarked before proceeding.

   /**
* Function to check certificate status
*
* @param {projectId} ProjectId
* @param {certId} CertId
*
* @returns {IResults<ICertStatusResult>} Returns certificate and status information.
*/
const result = await _mentaportSDK.getCertificateStatus(projectId:string, certId:string);

Once the content has succesfully been watermarked, the status will change from Initialized to Pending.

3. Approve Certificate

Approve the watermarked content and verify the information provided before creating the blockchain certificate. Once approved, the content will be available for download.

    /**
* Function to approve / non-approve a certificate before it generates NFT
*
* @param {projectId} ProjectId
* @param {certId} CertId from init content call
* @param {approve} Approve boolean
*
* @returns {IResults<ICertificate>} Returns certificate
*/
const result = await _mentaportSDK.approveCertificate(
projectId:string,
certId:string,
approved:boolean);

Once the certificate has been successfully approved, it will be executed on-chain, and the status will change to 'Active.'

4. Download Watermarked Content

Once the certificate has been successfully created, you're all set! Now you can download your newly watermarked content and distribute it fearlessly. Track it and rest assured that wherever it ends up, the provenance and ownership will be secure and traceable!

  /**
* Function to get download url of certificate
*
* @param {projectId} ProjectId
* @param {certId} certId
*
* @returns {url} Returns url to download watermarked content.
*/
const result = await _mentaportSDK.getDownloadUrl(projectId:string, certId:string);

5. Delete Certificate

Use this function to delete a certificate. You can only delete certificates that are in a Pending or NonActive state. Certificates that are already Active cannot be deleted to ensure the integrity and traceability of certified content as they are registered on the blockchain.

  /**
* Function to delete certificate
*
* @param {projectId} ProjectId
* @param {certId} certId
*
* @returns {IResults<ICertificate>} Returns deleted certificate.
*/
const result = await _mentaportSDK.deleteCertificate(projectId:string, certId:string);

Getters

These are read-only (getter) functions used to retrieve certificates data based on specific criteria. It does not modify any on-chain state.

1. Get Project Certificates

Each certificate is linked to a unique project. By default, every user has one project, but they can create additional projects to organize content by different stages or categories.

When querying for certificates, you can use the projectId to filter and retrieve certificates associated with a specific project. This helps keep your content organized and easy to manage.

  /**
* Function to get project certificates
*
* @param {projectId} ProjectId
*
* @returns {ICertificatesQuery} Returns all certificates per project.
* Each project certificate will be in its own array
*/
const result = await _mentaportSDK.getProjectCertificates(projectId:string):

2. Get Certificates

Use this function to retrieve certificates you’ve previously created, whether for viewing or verification purposes.

When querying for certificates, you can use limit and cursor parameters to paginate through results. By default, the function returns up to 100 certificates per page.

The response includes:

  • totalCount: total number of certificates
  • hasMore: a boolean indicating if there are more certificates available.
  • nextCursor: a cursor value you can use in the next query to fetch the following page of results.

This allows you to efficiently access large sets of certificates without overwhelming the system.

  /**
* Function to get certificates based on specified criteria.
*
* @param {GetCertificatesOptions} options - The options for fetching certificates
* - ProjectId: Filter certificates by project ID
* - CertId: Get a specific certificate by ID (requires projectId)
* - Cursor: Pagination cursor for fetching next page of results
* - Limit: Maximum number of certificates to return
*
* @returns {Promise<IResults<ICertificatesQuery>>} Returns paginated certificates matching the criteria
*/
// get all certificates
const result = await _mentaportSDK.getCertificates();

// get certificates with options
const result = await _mentaportSDK.getCertificates(options?: {
projectId?: string;
certId?: string;
cursor?: string;
limit?: number;});

3. Get Total Certificates

Use this function to get the total count of certificates per project.

  /**
* Function to get certificates based on specified criteria.
*
* @param {projectId} (optinal) projectId - To just get total of one project
* - if no projectId is provided, it will return total of all projects
*
* @returns {Promise<IResults<ICertificatesCount>>}
*/
const result = await _mentaportSDK.getTotalCertificates(projectId?: string);

Verify Content

The Mentaport SDK provides a straightforward method for checking if a piece of content contains a watermark and/or a C2PA manifest.

Start the verification process by uploading your content. Verification times range from approximately 1-20 seconds, depending on the size or length of the file uploaded (image, audio, video). After receiving the initial response, continue to check the status until you receive one of the following responses: NoCertificate or Certified.

  /**
* Function to verify if a piece of content has a certificate
*
* @param {contentFormat} contentFormat
* @param {urlFound} URL of where it was found
* @param {blobContent} content blob
*
* @returns {IResults<IVerify>} Returns verification status
*
*/
const result = await _mentaportSDK.verifyContent(
contentFormat:ContentFormat,
urlFound:string,
blobContent:Blob,
):

  /**
* Function to get verification progress status
*
* @param {verId} Id from verifyContent result
*
* @returns {IVerify} Returns verification status and certificate if found.
*/
const result = await _mentaportSDK.getVerificationStatus(verId:string):

Certificate Analytics

The Mentaport SDK offers a streamlined approach to access and review the analytics and tracking details of a certificate.

  /**
* Function to get certificates analytics
*
* @param {analytics} ICertificateAnalyticsArg
* - @param {queryDateStart} Query start date
* - @param {queryDateEnd} Query end date
* - @param {projectId} ProjectId
* - @param {certId} CertId
*
* @returns {ICertificatesQuery} Returns all certificates per project.
* Each project certificate will be in its own array
*/
const result = await _mentaportSDK.getCertificatesAnalytic(
analytics:ICertificateAnalyticsArg):

Checkout our examples to get started.